<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* 全局样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f5f7fa;
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        /* 登录容器 */
        .login-container {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
            padding: 30px;
            width: 100%;
            max-width: 400px;
        }

        /* 标题样式 */
        .login-title {
            text-align: center;
            margin-bottom: 25px;
            color: #2c3e50;
            font-size: 1.8rem;
            font-weight: 600;
        }

        /* 表单组样式 */
        .form-group {
            margin-bottom: 20px;
            position: relative;
        }

        .form-label {
            display: block;
            margin-bottom: 6px;
            color: #555;
            font-weight: 500;
            font-size: 0.9rem;
        }

        .form-input {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 1rem;
            transition: border-color 0.3s ease;
        }

        .form-input:focus {
            outline: none;
            border-color: #4a90e2;
        }

        .form-input::placeholder {
            color: #aaa;
        }

        /* 密码切换按钮 */
        .toggle-password {
            position: absolute;
            right: 12px;
            top: 60%;
            transform: translateY(-50%);
            color: #888;
            cursor: pointer;
            font-size: 0.9rem;
        }

        /* 选项组 */
        .options-group {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            font-size: 0.85rem;
        }

        .remember-me {
            display: flex;
            align-items: center;
            gap: 6px;
            cursor: pointer;
        }

        .remember-me input[type="checkbox"] {
            width: 16px;
            height: 16px;
        }

        .remember-me label {
            color: #555;
            cursor: pointer;
        }

        .forgot-password {
            color: #4a90e2;
            text-decoration: none;
        }

        .forgot-password:hover {
            text-decoration: underline;
        }

        /* 登录按钮 */
        .login-btn {
            width: 100%;
            padding: 12px;
            background-color: #4a90e2;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        .login-btn:hover {
            background-color: #357abd;
        }

        /* 分隔线 */
        .divider {
            display: flex;
            align-items: center;
            margin: 25px 0;
            color: #888;
            font-size: 0.85rem;
        }

        .divider::before,
        .divider::after {
            content: '';
            flex: 1;
            height: 1px;
            background-color: #e0e0e0;
            margin: 0 10px;
        }

        /* 社交登录 */
        .social-login {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

        .social-btn {
            flex: 1;
            padding: 8px 0;
            border: 1px solid #ddd;
            border-radius: 4px;
            background-color: white;
            color: #555;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 1rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .social-btn:hover {
            background-color: #f8f9fa;
        }

        /* 注册链接 */
        .register-link {
            text-align: center;
            margin-top: 20px;
            font-size: 0.85rem;
            color: #555;
        }

        .register-link a {
            color: #4a90e2;
            text-decoration: none;
            font-weight: 500;
        }

        .register-link a:hover {
            text-decoration: underline;
        }

        /* 错误提示 */
        .error-message {
            color: #e74c3c;
            font-size: 0.8rem;
            margin-top: 4px;
            display: none;
        }

        /* 响应式设计 */
        @media (max-width: 480px) {
            .login-container {
                padding: 20px;
            }

            .login-title {
                font-size: 1.6rem;
            }
        }
    </style>
</head>

<body>
    <div class="login-container">
        <h1 class="login-title">用户登录</h1>
        
        <form id="loginForm" onsubmit="return validateForm()">
            <!-- 用户名输入 -->
            <div class="form-group">
                <label for="username" class="form-label">用户名</label>
                <input type="text" id="username" class="form-input" placeholder="请输入用户名" required>
                <div id="usernameError" class="error-message">请输入有效的用户名</div>
            </div>

            <!-- 密码输入 -->
            <div class="form-group">
                <label for="password" class="form-label">密码</label>
                <input type="password" id="password" class="form-input" placeholder="请输入密码" required>
                <i class="fas fa-eye-slash toggle-password" id="togglePassword" onclick="togglePasswordVisibility()"></i>
                <div id="passwordError" class="error-message">密码不能为空</div>
            </div>

            <!-- 选项组 -->
            <div class="options-group">
                <div class="remember-me">
                    <input type="checkbox" id="rememberMe">
                    <label for="rememberMe">记住我</label>
                </div>
                <a href="#" class="forgot-password">忘记密码？</a>
            </div>

            <!-- 登录按钮 -->
            <button type="submit" class="login-btn">登录</button>

            <!-- 分隔线 -->
            <div class="divider">或</div>

            <!-- 社交登录 -->
            <div class="social-login">
                <button type="button" class="social-btn" title="使用Facebook账号登录">
                    <i class="fab fa-facebook-f"></i>
                </button>
                <button type="button" class="social-btn" title="使用Google账号登录">
                    <i class="fab fa-google"></i>
                </button>
                <button type="button" class="social-btn" title="使用GitHub账号登录">
                    <i class="fab fa-github"></i>
                </button>
            </div>

            <!-- 注册链接 -->
            <div class="register-link">
                还没有账号？<a href="#">立即注册</a>
            </div>
        </form>
    </div>

    <script>
        // 验证表单
        function validateForm() {
            let isValid = true;
            
            // 验证用户名
            const username = document.getElementById('username').value.trim();
            const usernameError = document.getElementById('usernameError');
            
            if (username.length < 3) {
                usernameError.textContent = '用户名至少需要3个字符';
                usernameError.style.display = 'block';
                isValid = false;
            } else {
                usernameError.style.display = 'none';
            }
            
            // 验证密码
            const password = document.getElementById('password').value;
            const passwordError = document.getElementById('passwordError');
            
            if (password.length < 6) {
                passwordError.textContent = '密码至少需要6个字符';
                passwordError.style.display = 'block';
                isValid = false;
            } else {
                passwordError.style.display = 'none';
            }
            
            if (isValid) {
                // 这里可以添加实际的登录逻辑
                alert('登录成功！用户名: ' + username);
                // 通常这里会发送请求到服务器进行验证
                // 例如: submitLoginData(username, password);
            }
            
            return false; // 阻止表单默认提交，使用JavaScript处理
        }
        
        // 切换密码可见性
        function togglePasswordVisibility() {
            const passwordInput = document.getElementById('password');
            const toggleIcon = document.getElementById('togglePassword');
            
            if (passwordInput.type === 'password') {
                passwordInput.type = 'text';
                toggleIcon.classList.remove('fa-eye-slash');
                toggleIcon.classList.add('fa-eye');
            } else {
                passwordInput.type = 'password';
                toggleIcon.classList.remove('fa-eye');
                toggleIcon.classList.add('fa-eye-slash');
            }
        }
        
        // 社交登录按钮点击事件
        document.querySelectorAll('.social-btn').forEach(btn => {
            btn.addEventListener('click', function() {
                const platform = this.title.replace('使用', '').replace('账号登录', '');
                alert(`正在跳转到${platform}授权页面...`);
                // 实际项目中这里会重定向到相应的OAuth授权页面
            });
        });
        
        // 忘记密码链接点击事件
        document.querySelector('.forgot-password').addEventListener('click', function(e) {
            e.preventDefault();
            alert('忘记密码功能尚未实现');
        });
        
        // 注册链接点击事件
        document.querySelector('.register-link a').addEventListener('click', function(e) {
            e.preventDefault();
            alert('注册功能尚未实现');
        });
    </script>
</body>

</html>